{{>licenseInfo}}

package {{package}};

import {{invokerPackage}}.ApiCallback;
import {{invokerPackage}}.ApiClient;
import {{invokerPackage}}.ApiException;
import {{invokerPackage}}.ApiResponse;
import {{invokerPackage}}.Configuration;
import {{invokerPackage}}.Pair;
import {{invokerPackage}}.ProgressRequestBody;
import {{invokerPackage}}.ProgressResponseBody;
{{#performBeanValidation}}
import {{invokerPackage}}.BeanValidationException;
{{/performBeanValidation}}

import com.google.gson.reflect.TypeToken;
import com.dhcc.client.api.PublicApi;
import java.io.IOException;
BBBBBBBBBBBBBBBBBBBBBBBBB
{{#useBeanValidation}}
import javax.validation.constraints.*;
{{/useBeanValidation}}
{{#performBeanValidation}}
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.ValidatorFactory;
import javax.validation.executable.ExecutableValidator;
import java.util.Set;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
{{/performBeanValidation}}

{{#imports}}import {{import}};
{{/imports}}

import java.lang.reflect.Type;
{{^fullJavaUtil}}
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
{{/fullJavaUtil}}

import java.text.SimpleDateFormat;
import java.util.Date;

import com.dhcc.client.api.ApiException;
import com.dhcc.util.PropertiesUtil;
import com.google.gson.Gson;

import lombok.extern.slf4j.Slf4j;

{{#operations}}
@Slf4j
public class {{classname}} {
	private PublicApi api;

	{{#operation}}
	//url of method {{operationId}}
    String {{operationId}}Url;
    //serviceCode of method {{operationId}}
    String {{operationId}}Code;			
	{{/operation}}
		  
	public {{classname}}() {
    	try {
			init();
		} catch (Exception e) {
			log.error("please check configuration file gateway.properties!");
			e.printStackTrace();
		}
    }
	private void init() throws Exception{

		api = new PublicApi();

	{{#operation}}
        {{operationId}}Url = PropertiesUtil.getVal("gateway.request.{{{classname}}}.{{{operationId}}}.url");
        if ({{operationId}}Url == null) {{operationId}}Url = "";
    	{{operationId}}Code = PropertiesUtil.getVal("gateway.request.{{{classname}}}.{{{operationId}}}.servicecode");
    	if ({{operationId}}Code == null) {{operationId}}Code = "";			
	{{/operation}}
	}
	
    {{#operation}}
    {{^pathParams}}
    {{^headerParams}}
    {{^formParams}}
    {{^vendorExtensions.x-group-parameters}}
    /** 
     *  public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException
     * {{summary}}
     * {{notes}}{{#allParams}}
     * @param {{paramName}} {{description}}{{#required}} (required){{/required}}{{^required}} (optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{/allParams}}{{#returnType}}
     * @return {{{returnType}}}{{/returnType}}
     * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
     {{#isDeprecated}}
     * @deprecated
     {{/isDeprecated}}
        {{#externalDocs}}
     * {{description}}
     * @see <a href="{{url}}">{{summary}} Documentation</a>
        {{/externalDocs}}
     */
    {{#isDeprecated}}
    @Deprecated
    {{/isDeprecated}}
    public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{#-first}}{{{dataType}}} request{{/-first}}{{/allParams}}) throws ApiException {
		{{^hasParams}}Object request = new Object();{{/hasParams}}
		log.info("begin to {{{httpMethod}}} the real path: {{{path}}}");
		{{#returnType}}
		{{#returnSimpleType}}
		return api.requestPublic(request, {{operationId}}Code, {{operationId}}Url, {{{returnType}}}.class, "{{{httpMethod}}}");
		{{/returnSimpleType}}
		{{#isMapContainer}}
		return api.requestPublic(request, {{operationId}}Code, {{operationId}}Url, Map.class, "{{{httpMethod}}}");
		{{/isMapContainer}}
		{{#isListContainer}}
		return api.requestPublic(request, {{operationId}}Code, {{operationId}}Url, List.class, "{{{httpMethod}}}");
		{{/isListContainer}}
		{{/returnType}}
		{{^returnType}} 
		
		api.requestNoReturn(request, {{operationId}}Code, {{operationId}}Url, "{{{httpMethod}}}");
    	{{/returnType}}
    }
    
    {{/vendorExtensions.x-group-parameters}}  
    {{/formParams}}
    {{/headerParams}}
    {{/pathParams}}
    {{/operation}}    
}
{{/operations}}
